home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Space & Astronomy
/
Space and Astronomy (October 1993).iso
/
mac
/
VIEWERS
/
AMIGA
/
GIFTOIF2.LZH
/
GIFtoIFF.doc
< prev
next >
Wrap
Text File
|
1992-08-06
|
9KB
|
201 lines
GIFtoIFF Version 2.0
I. Introduction
This set of programs was written to satisfy my curiousity.
They were uploaded to a local BBS to gain more download
time and now they've come back to haunt me. I thought the BBS
would delete it.
The first version was quickly written and had a lot of bugs.
I've since stomped on all of the ones I know about. I've
re-written most of the code to speed it up considerably and
I've added new features and programs, such as EHB, GIFhdr
and TmpX. Read the file Release2.0 for more details.
These programs convert GIF files into many of the Amiga IFF
formats. They are mainly for converting GIF files that have
more colors than the Amiga can currently handle, but they
will convert the others as well. The programs themselves aren't
real user friendly, but do allow themselves to be run in scripts.
I usually set up a script and let my Amiga convert a bunch of
images while I'm doing something else. See the section on Convert
farther down.
These programs may and should be freely distributed. No money
need be sent. I will try to support them the best I can, but
work's been taking most of my time as of late.
If new modes for the Amiga are invented, become stable and
viewers for those new modes become widely available, I'll
add them to my programs. I've heard of a couple new modes
that use copper lists to change color registers on a per
line basis. I'd like to hear more about those modes.
II. File Summary
Below is a list of the files included in this package and briefly
what they do. The Usage of each of these files can be obtained
by just typing the file name. The exception is the script file
Convert and its usage is at the end of this section.
The stack should be set to 8000 or 16000 for larger files.
GIFhdr Gives information about a GIF file
GIFtoTMP Converts GIF files into TMP files.
Exits with Warn if file is interlaced.
Look at Convert to see how it's used.
Unlace Will unlace a TMP file. Use only if
GIFtoTMP indicates the file as Interlaced or
if you like scrambled pictures.
TMPtoIFF Converts TMP files into IFF files
TmpX Extracts a section of a TMP file. Useful for
breaking up those 640x400x256 files into a
384x400 file. Usually you don't miss too much.
convert A CLI script file I use to convert the images
from GIF to IFF.
convert giffilepath giffilename [opt1 opt2] [NOTMP]
giffilepath is the path to the directory in which
the gif file is located.
giffile is the name of the file to convert
(with or without the .gif extension).
Convert looks for both.
opt1,opt2 are options which get passed to tmptoiff.
NOTMP must be the third option(for now) and
tells Convert to delete <giffile>.tmp
when Convert is done with it.
Notes on Convert:
- G2I: needs to be assigned to the directory that
contains GIFtoTMP,Unlace and TMPtoIFF.
- The final file is called <giffile>.pic and is placed
in the local directory.
- Intermediate files <giffile>.ltmp and <giffile>.tmp
are used by Unlace and GIFtoTMP, respectively. These
will OVERWRITE any existing files by that name.
- If the NOTMP option is not specified, <giffile>.tmp
will still exist at the end of the script.
- If convert finds <giffile>.tmp to exist at the start,
it will jump directly to TMPtoIFF, bypassing GIFtoTMP
and Unlace. I find it useful.
III. TMP File Format
The TMP File Format is yet another format. At the time I originally
wrote this, I wasn't familiar with FBM or PBMPlus formats or I
would've used one of those. But would I have been able to pass
this along with those formats? What follows is a brief description
of the format.
struct TMPFILE
{
SHORT ImageWidth,ImageHeight,NoOfColorRegisters;
Struct COLORREGISTER ColorRegisters[NoOfColorRegisters];
UBYTE Image[ImageHeight][ImageWidth];
}
where struct COLORREGISTER is
struct COLORREGISTER
{
UBYTE red,green,blue;
}
** Note that the picture is Image[y][x] not Image[x][y] **
The Image array indexes into the ColorRegisters array, which holds
the actual color values. For example-The red component of a pixel
(x,y) is given by the value of ColorRegisters[Image[y][x]].red.
A value of 255 is all the way on. A value of 0 is all the way
off. Since the Amiga can only display 4 bits per color component
the following equation should be used:
temp=ColorRegisters[Image[y][x]].red
RedComponent = (tmp>>4) & 0x0f;
And'ing the value with 0x0f probably isn't necessary but helps
conceptually.
III. Quantization Algorithms Used
The following briefly describes the three current choices
the program TMPtoIFF gives for selecting the 'best' y number
of colors from the original ones.
Popularity-Chooses the most used colors from the histogram.
Median Cut-Thinks of the colors as points in three dimensional
space (Red,Green,Blue) and draws a box that
encloses all points. The program then divides that
box into two boxes with an equal number of colors in
each side. (A pure white screen would only have one
color-even though that color is used in thousands of
pixels)
The boxes are continuously divided along their
longest axis until there are as many boxes as the
number of colors that you want. Then the colors in
each box are averaged and those values are used for
the final color map.
Weighted Median Cut-I modified the above algorithm so that as
it's dividing each box along the longest axis, it
tries to put an equal number of pixels in each side
(which of course is impossible to do exactly)
This produces averaged colors closer to the majority
colors(as in Popularity), but also provides the variety
that the Median Cut algorithm does.
After one of the above algorithms is run, each pixel in the
original image is replaced with the closest value in the final
color map.
If an EHB(Extra Half Brite) image is requested, one of the above
methods is used to come up with 32 colors. Each of these colors is
then used to produce 32 more colors by dividing each component(red,
green and blue) by two. This gives a final color map of 64 colors.
If a HAM image is requested, the program uses one of the above
algorithms to produce the 16 base colors used in HAM mode.
Extra Half Brite support is experimental at best. I tried a couple
quick methods to shift color selection to the brighter colors, since
the second set of 32 colors is just a darker version of the first
set. I also look through the first set to weed out dark colors that
will be produced by creating the second set.
When it comes to images, EHB isn't very useful since HAM does a better
job with the same amount of memory(of course there's exceptions, but
they probably have to be thought out and won't occur naturally).
IV Closing Monologue
Thanks for using this and I hope it proves to be useful.
Any questions, comments or information that I might find useful
please send to the following address.
Mark Podlipec
27-7 Yorkshire Terrace
Shrewsbury MA 01545
I used to read comp.sys.amiga regularly until our feed got yanked.
Hopefully, it'll be back soon.